package com.yycx.module.bus.provider.handler.haiying.tasktodo.settle.apply;

import com.yycx.common.constants.CommonConstants;
import com.yycx.module.bus.provider.service.BusPaymentService;
import com.yycx.module.bus.provider.service.hy.BusHyorderInoviceDetailsService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 费用结算申请审批结束监听器
 *
 * @author zyf
 */
@Component
public class HySettleApply2ProcessEndListener implements ExecutionListener {
    @Resource
    private BusPaymentService paymentService;

    @Resource
    private BusHyorderInoviceDetailsService hyorderInoviceDetailsService;

    @Override
    public void notify(DelegateExecution delegateExecution) {
        String businessKey = delegateExecution.getProcessInstanceBusinessKey();
        hyorderInoviceDetailsService.insertInvoiceDetails(businessKey);
        paymentService.updatePaymentState(Long.parseLong(businessKey), CommonConstants.INT_2);
    }
}
